package com.byhq;

import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) {
		/**
		 * 三次登录机会
		 */
    	Scanner scanner=new Scanner(System.in);
    	int times=3;
    	while(true) {
    		System.out.println("请输入用户名");
    		String name=scanner.nextLine();
    		System.out.println("请输入密码");
    		String pwd=scanner.nextLine();
    		if(name.equals("jack") && pwd.equals("123")) {
    			System.out.println("登录成功");
    			break;
    		}else {
    			System.out.println("您还有"+(--times)+"次机会");
    		}
    		if(times<=0) {
    			break;
    		}
    	}
	}
}
